home *** CD-ROM | disk | FTP | other *** search
/ One Click 21 (Special) / OC021.iso / Juegos / King of Skeleton / King of Skeleton.swf / scripts / __Packages / Track.as < prev    next >
Encoding:
Text File  |  2006-02-02  |  4.4 KB  |  143 lines

  1. class Track extends Array
  2. {
  3.    var scenery;
  4.    var oscen;
  5.    var pickups;
  6.    var opicks;
  7.    var warnings;
  8.    var owarn;
  9.    var scale = 1;
  10.    var vscale = 1;
  11.    var l = 0;
  12.    var angle = 0;
  13.    function Track()
  14.    {
  15.       super();
  16.       if(arguments.length > 1)
  17.       {
  18.          this.splice.apply(this,[0,0].concat(arguments));
  19.       }
  20.       else if(arguments.length == 1)
  21.       {
  22.          var _loc4_ = 0;
  23.          while(_loc4_ < arguments[0])
  24.          {
  25.             this[_loc4_] = undefined;
  26.             _loc4_ = _loc4_ + 1;
  27.          }
  28.       }
  29.    }
  30.    function reset()
  31.    {
  32.       this.scenery = this.oscen.copy();
  33.       this.pickups = this.opicks.copy();
  34.       this.warnings = this.owarn.copy();
  35.    }
  36.    function setScenery(s)
  37.    {
  38.       this.oscen = s;
  39.       this.scenery = s.copy();
  40.    }
  41.    function setPickups(p)
  42.    {
  43.       this.opicks = p;
  44.       this.pickups = p.copy();
  45.    }
  46.    function setWarnings(w)
  47.    {
  48.       this.owarn = w;
  49.       this.warnings = w.copy();
  50.    }
  51.    function analyse(ia)
  52.    {
  53.       this.angle = ia != undefined ? ia : this.angle;
  54.       var _loc4_ = 0;
  55.       var _loc3_ = 0;
  56.       var _loc2_ = 0;
  57.       while(_loc2_ < this.length)
  58.       {
  59.          this[_loc2_].a = this.angle;
  60.          this[_loc2_].z *= this.vscale;
  61.          if(this[_loc2_].s)
  62.          {
  63.             this[_loc2_].l *= this.scale;
  64.             this[_loc2_].x = _loc4_;
  65.             this[_loc2_].y = _loc3_;
  66.             _loc4_ += this[_loc2_].l * Math.cos(this[_loc2_].a);
  67.             _loc3_ += this[_loc2_].l * Math.sin(this[_loc2_].a);
  68.          }
  69.          else
  70.          {
  71.             this[_loc2_].c *= Trig.dr;
  72.             this[_loc2_].r *= this.scale;
  73.             this[_loc2_].l = this[_loc2_].r * this[_loc2_].c;
  74.             this.angle += this[_loc2_].c * this[_loc2_].d;
  75.             this[_loc2_].x = _loc4_;
  76.             this[_loc2_].y = _loc3_;
  77.             var _loc5_ = this[_loc2_].a + Trig.ra * this[_loc2_].d;
  78.             this[_loc2_].cx = _loc4_ + this[_loc2_].r * Math.cos(_loc5_);
  79.             this[_loc2_].cy = _loc3_ + this[_loc2_].r * Math.sin(_loc5_);
  80.             _loc4_ = this[_loc2_].cx + this[_loc2_].r * Math.cos(this[_loc2_].c * this[_loc2_].d + this[_loc2_].a - Trig.ra * this[_loc2_].d);
  81.             _loc3_ = this[_loc2_].cy + this[_loc2_].r * Math.sin(this[_loc2_].c * this[_loc2_].d + this[_loc2_].a - Trig.ra * this[_loc2_].d);
  82.          }
  83.          this[_loc2_].n = this[_loc2_ + 1];
  84.          this[_loc2_].tl = this.l;
  85.          this.l += this[_loc2_].l;
  86.          _loc2_ = _loc2_ + 1;
  87.       }
  88.    }
  89.    function viewOffset(cts, ccd, player)
  90.    {
  91.       if(cts.s)
  92.       {
  93.          if(player.ts.s)
  94.          {
  95.             return 0;
  96.          }
  97.          var _loc11_ = Vector.lineIntersection(player.v,new Vector(player.v.x + Math.cos(player.a),player.v.y + Math.sin(player.a)),new Vector(cts.x,cts.y),new Vector(cts.x + Math.cos(cts.a),cts.y + Math.sin(cts.a)));
  98.          var _loc8_ = cts.a - player.a;
  99.          return Vector.vectDist(player.v,_loc11_) * Math.tan(_loc8_);
  100.       }
  101.       if(!player.ts.s && player.ts != cts)
  102.       {
  103.          var _loc13_ = new Vector(cts.cx,cts.cy);
  104.          var _loc6_ = new Vector(cts.cx + cts.r * Math.cos(player.a),cts.cy + cts.r * Math.sin(player.a));
  105.          var _loc5_ = new Vector(player.v.x + ccd * Math.cos(player.a),player.v.y + ccd * Math.sin(player.a));
  106.          var _loc7_ = Vector.cpol(_loc13_,_loc6_,_loc5_);
  107.          var _loc12_ = Vector.vectDist(_loc7_,_loc5_);
  108.          var _loc3_ = Vector.vectDist(_loc6_,_loc7_);
  109.          _loc3_ = _loc3_ <= cts.r ? cts.r - _loc3_ : _loc3_ % cts.r;
  110.          var _loc10_ = Trig.xaty(cts.r,_loc3_);
  111.          return (_loc10_ - _loc12_) * (cts.d * -1);
  112.       }
  113.       var _loc4_ = cts.tl - player.d;
  114.       _loc4_ = _loc4_ > 0 ? _loc4_ : 0;
  115.       return (cts.r - Trig.xaty(cts.r,ccd - _loc4_)) * cts.d;
  116.    }
  117.    function getHeightAt(ts, d)
  118.    {
  119.       var _loc2_ = ts.z - (!ts.n ? 0 : ts.n.z);
  120.       return Sine.easeInOut(d - ts.tl,ts.z,- _loc2_,ts.l);
  121.    }
  122.    function copy()
  123.    {
  124.       var _loc2_ = new Track();
  125.       for(var _loc3_ in this)
  126.       {
  127.          _loc2_[_loc3_] = this[_loc3_];
  128.       }
  129.       return _loc2_;
  130.    }
  131.    function toString()
  132.    {
  133.       var _loc3_ = "";
  134.       var _loc2_ = 0;
  135.       while(_loc2_ < this.length)
  136.       {
  137.          _loc3_ += this[_loc2_].s + ", " + this[_loc2_].l + "\n";
  138.          _loc2_ = _loc2_ + 1;
  139.       }
  140.       return _loc3_;
  141.    }
  142. }
  143.